#include <stdio.h>

int sel(int arr[4][4], int* px, int* py, int k)
{	
	int x = 0;
	int y = *py - 1;
	while (x < *px && y < *py)
	{
		if (arr[x][y] < k)
			x++;
		else if (arr[x][y] > k)
			y--;
		else if(arr[x][y] == k)
		{
			*px = x;
			*py = y;
			return 1;
		}
		else
			return 0;
	}
}

int main() 
{
	int arr[4][4] = { {1,2,3,4},{5,6,7,8},{9,10,11,12}, {13,14,15,16} };
	int x = 4;
	int y = 4;
	int k = 8;
	int ret = sel(arr, &x, &y, k);
	if (ret == 1)
		printf("arr[%d][%d]\n", x, y);
	else
		printf("无\n");
	return 0;
}
